package main

import "fmt"

func main() {
	//求数组和
	a12 := [...]int{1, 3, 5, 7, 8}
	sum := 0
	for i := 0; i < len(a12); i++ {
		sum += a12[i]
	}
	fmt.Println(sum)

	/* 	for _, v := range a12 {
	   		sum += v
	   	}
	   	fmt.Println(sum) */

	//求和是8的
	a13 := [...]int{1, 3, 5, 7, 8}
	fmt.Println("根据索引值取出：")
	for i := 0; i < len(a13); i++ {
		for j := i + 1; j < len(a13); j++ {
			if a13[i]+a13[j] == 8 {
				fmt.Printf("(%d,%d) \n", i, j)
			}
		}
	}
}
